//
// Created by Administrator on 2016/9/30.
//

#include "ShareHeaders.h"

void ZainTL::uintToByteArray(uint64_t number, char *array, uint8_t byteNum) {
    for (unsigned char i = 0; i < byteNum; ++i) {
        array[i] = number >> (8 * i);
    }
    /*array[7] = (unsigned char) (number >> 56);
    array[6] = (unsigned char) (number >> 48);
    array[5] = (unsigned char) (number >> 40);
    array[4] = (unsigned char) (number >> 32);
    array[3] = (unsigned char) (number >> 24);
    array[2] = (unsigned char) (number >> 16);
    array[1] = (unsigned char) (number >> 8);
    array[0] = (unsigned char) (number);*/
}

uint64_t ZainTL::byteArrayToUint(char *array, uint8_t byteNum) {
    uint64_t result = 0;
    for (unsigned char i = 0; i < byteNum; ++i) {
        result += (unsigned char) array[i] << (8 * i);
    }
    return result;
}